package com.zhongyu.comm.vo;

import lombok.Data;

import java.io.Serializable;

public class Result implements Serializable {
    private boolean success;

    private String errorCode;

    private String msg;

    private Object data;

    public static Result success(Object data){
        Result result=new Result();
        result.setErrorCode("0000");
        result.setSuccess(true);
        result.setData(data);
        return result;
    }

    public static Result success(Object data,String errorCode){
        Result result=new Result();
        result.setErrorCode(errorCode);
        result.setSuccess(true);
        result.setData(data);
        return result;
    }

    public static Result failure(String msg){
        Result result=new Result();
        result.setErrorCode("5000");
        result.setSuccess(false);
        result.setMsg(msg);
        return result;
    }

    public static Result failure(String msg,String errorCode){
        Result result=new Result();
        result.setErrorCode(errorCode);
        result.setSuccess(false);
        result.setMsg(msg);
        return result;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
